/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package com.unimod.fsmleditor;

import org.eclipse.ui.plugin.*;
import org.eclipse.jface.text.rules.RuleBasedScanner;

import com.unimod.fsmleditor.configuration.FSMLColorProvider;
import com.unimod.fsmleditor.configuration.scanner.FSMLCodeScanner;
import com.unimod.fsmleditor.configuration.scanner.FSMLDocScanner;
import com.unimod.fsmleditor.configuration.scanner.FSMLPartitionScanner;

/**
 * The FSML editor plug-in class.
 */
public class FSMLEditorPlugin extends AbstractUIPlugin {

	public final static String FSML_PARTITIONING = "__fsml_partitioning";
	
	//The shared instance.
	private static FSMLEditorPlugin plugin;

	private static FSMLPartitionScanner fPartitionScanner;
	private static FSMLColorProvider fColorProvider;
	private static FSMLCodeScanner fCodeScanner;
	private static FSMLDocScanner fDocScanner;

	/**
	 * Creates a new plug-in instance.
	 */
	public FSMLEditorPlugin() {
		plugin = this;
	}

	/**
	 * Returns the default plug-in instance.
	 * 
	 * @return the default plug-in instance
	 */
	public static FSMLEditorPlugin getDefault() {
		return plugin;
	}

	/**
	 * Return a scanner for creating FSML partitions.
	 * 
	 * @return a scanner for creating FSML partitions
	 */
	 public static FSMLPartitionScanner getFSMLPartitionScanner() {
		if (fPartitionScanner == null)
			fPartitionScanner= new FSMLPartitionScanner();
		return fPartitionScanner;
	}

	/**
	 * Returns the singleton FSML code scanner.
	 * 
	 * @return the singleton FSML code scanner
	 */
	 public static RuleBasedScanner getFSMLCodeScanner() {
	 	if (fCodeScanner == null)
			fCodeScanner = new FSMLCodeScanner(getFSMLColorProvider());
		return fCodeScanner;
	}
	
	/**
	 * Returns the singleton FSML color provider.
	 * 
	 * @return the singleton FSML color provider
	 */
	 public static FSMLColorProvider getFSMLColorProvider() {
	 	if (fColorProvider == null)
			fColorProvider = new FSMLColorProvider();
		return fColorProvider;
	}
	
	/**
	 * Returns the singleton FSMLdoc scanner.
	 * 
	 * @return the singleton FSMLdoc scanner
	 */
	 public static RuleBasedScanner getFSMLDocScanner() {
	 	if (fDocScanner == null)
			fDocScanner = new FSMLDocScanner(fColorProvider);
		return fDocScanner;
	}
}
